{% extends 'backend_layout.html' %}
{% block css %}

{% endblock %}
{% block conent %}
    <ol class="breadcrumb">
        <li><a href="#">标签管理</a></li>
        <li class="active">标签列表</li>
    </ol>
    <div>
        <div class="row" style="padding: 20px 5px;">
            <form class="form-horizontal" id="tag_form">
                {% csrf_token %}
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-xs-1 control-label">标签名</label>

                        <div class="col-xs-3 relative">
                            <input type="text" class="form-control" id="title" name="title" placeholder="请输入标签名">
                            <div class="error_msg" error="title"></div>
                        </div>
                        <div class="col-xs-3">
                            <input type="submit" role="tag" class="btn btn-primary" value="添 加">
                        </div>
                    </div>
                </div>
            </form>
        </div>

        <div style="height: 35px;background-color: #f5f5f5;line-height: 35px;padding: 0 15px;">
            <i class="fa fa-table" aria-hidden="true"></i>
            标签列表
        </div>

        <table class="table table-bordered">
            <thead>
            <tr>
                <th>标签</th>
                <th>文章个数</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {% for row in tag_list %}
                <tr>
                    <td>{{ row.title }}</td>
                    <td>{{ row.article_set.count }}</td>
                    <td>
                        <a class="btn btn-danger btn-xs del_btn" href="/backend/del_tag/" nid="{{ row.nid }}">
                            <i class="fa fa-times" aria-hidden="true"></i>
                            删除
                        </a>
                        |
                        <a class="btn btn-primary btn-xs edit_btn" href="/backend/edit_tag/" nid="{{ row.nid }}">
                            <i class="fa fa-pencil-square-o" aria-hidden="true"></i>
                            编辑
                        </a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>

        <div class="clearfix">
            <ul class="pagination right" style="margin-top: 0">
                {{ page_str }}
            </ul>
        </div>
    </div>

    <div class="modal fade" id="editTitleModel">
        <div class="modal-dialog">
            <div class="modal-content message_align">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                    <h4 class="modal-title">修改标签名称</h4>
                </div>
                <div class="modal-body">
                    <p id="confirm_content"><input type="text" class="form-control" id="edit_title" name="title" placeholder="请输入标签名称"></p>
                </div>
                <div class="modal-footer">
                    <input type="hidden" id="edit_url"/>
                    <input type="hidden" id="edit_nid"/>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <a id="edit_submit" class="btn btn-success" data-dismiss="modal">确定</a>
                </div>
            </div>
        </div>
    </div>


    <div class="modal fade" id="errorMsgModel">
        <div class="modal-dialog">
            <div class="modal-content message_align">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                    <h4 class="modal-title">标签名称更新失败</h4>
                </div>
                <div class="modal-body">
                    <p id="errormsg_content"></p>
                </div>
                <div class="modal-footer">
                    <input type="hidden" id="edit_url"/>
                    <input type="hidden" id="edit_nid"/>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <a id="edit_submit" class="btn btn-success" data-dismiss="modal">确定</a>
                </div>
            </div>
        </div>
    </div>

    {% include 'include/del_confirm.html' %}
{% endblock %}

{% block js %}
    <script src="/static/js/jquery-1.12.4.js"></script>
    <script src="/static/js/jquery.cookie.js"></script>
    <script src="/static/plugins/bootstrap/js/bootstrap.js"></script>
    <script src="/static/js/common.js"></script>
    <script src="/static/js/backend.js"></script>
    <script src="/static/js/account.js"></script>
{% endblock %}